package com.lin.order.Controller;



import com.lin.order.Bean.Order;
import com.lin.order.Service.OrderService;
import com.lin.order.properties.OrderProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@RefreshScope //开启配置刷新功能
public class OrderController {

    @Autowired
    OrderService orderService;

//    @Value("${order.timeout}")
//    String orderTimeout;
//
//    @Value("${order.auto-confirm}")
//    String autoConfirm;

    @Autowired
    OrderProperties orderProperties;

    @GetMapping("/create")
    public Order createOrder(@RequestParam Long UserId, @RequestParam Long ProductId){
        return orderService.createOrder(UserId,ProductId);
    }

    @GetMapping("/config")
    public String getConfig(){
        return "orderTimeout:"+orderProperties.getTimeout()+" autoConfirm:"+orderProperties.getAutoConfirm()
                +"order-database-url:"+orderProperties.getDbUrl();

    }


}
